home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / System Extras Headers / XTND Headers / XTNDInterface.h next >
Encoding:
C/C++ Source or Header  |  1994-01-10  |  13.7 KB  |  357 lines  |  [TEXT/MMCC]

  1. /*
  2.     File:        XTNDInterface.h
  3.  
  4.     Copyright:    © 1984-1993 by Apple Computer, Inc., all rights reserved.
  5.  
  6.     WARNING
  7.     This file was auto generated by the interfacer tool. Modifications
  8.     must be made to the master file.
  9.  
  10. */
  11.  
  12. #ifndef __XTNDINTERFACE__
  13. #define __XTNDINTERFACE__
  14.  
  15. #include <Types.h>
  16. /*    #include <ConditionalMacros.h>                                */
  17. /*    #include <MixedMode.h>                                        */
  18. /*        #include <Traps.h>                                        */
  19. #include <StandardFile.h>
  20. /*    #include <Dialogs.h>                                        */
  21. /*        #include <Windows.h>                                    */
  22. /*            #include <Quickdraw.h>                                */
  23. /*                #include <QuickdrawText.h>                        */
  24. /*                    #include <IntlResources.h>                    */
  25. /*            #include <Events.h>                                    */
  26. /*                #include <OSUtils.h>                            */
  27. /*            #include <Controls.h>                                */
  28. /*                #include <Menus.h>                                */
  29. /*        #include <TextEdit.h>                                    */
  30. /*    #include <Files.h>                                            */
  31. /*        #include <SegLoad.h>                                    */
  32.  
  33. /* ———— Prototypes for XTND system calls are at the end of this file (for THINK C) ———— */
  34.  
  35.  
  36. /* ———— Defines for XTND Version ———— */
  37.  
  38. #define xtndVersion 2
  39.  
  40.  
  41. /* ———— Defines for XTND Gestalt Selector  ———— */
  42.  
  43. #define gestaltXTNDAttr 'XTND'
  44.  
  45. #define gestaltPPCXTNDPresent 1
  46.  
  47.  
  48. /* ———— Defines for file types ———— */
  49.  
  50. #define xtndTranslatorFileType 'Fltr'
  51.  
  52.  
  53. /* ———— Defines for resource types ———— */
  54.  
  55. #define translatorDescription 'FTYP'
  56.  
  57. #define textImportType 'FLTI'
  58.  
  59. #define textExportType 'FLTE'
  60.  
  61. #define pictImportType 'PFLT'
  62.  
  63.  
  64. /* ———— Characteristics values for Flags field in TransDescribe and FTYP ———— */
  65.  
  66. #define ftypIsSpecial 0x0001
  67.  
  68. #define ftypHasPreferences 0x0002
  69.  
  70. #define ftypNeedsResources 0x0004
  71.  
  72. #define ftypWritesResources 0x0008
  73.  
  74. #define ftypOnlyPreferences 0x0010
  75.  
  76. #define ftypIsLocalized 0x0020
  77.  
  78.  
  79. /* ———— Type of translators to be included in list ———— */
  80.  
  81. #define allowTypeMask 0x00FF
  82.  
  83. #define allowText 0x0001
  84.  
  85. #define allowGraphics 0x0002
  86.  
  87. #define allowDataBase 0x0004
  88.  
  89. #define allowPict 0x0008
  90.  
  91. #define allowOtherTypes 0x0080
  92.  
  93. #define allowAllTypes 0x00FF
  94.  
  95.  
  96. /* ———— Use of translators to be included in list ———— */
  97.  
  98. #define allowUseMask 0xFF00
  99.  
  100. #define allowImport 0x0100
  101.  
  102. #define allowExport 0x0200
  103.  
  104. #define allowOtherUses 0x8000
  105.  
  106. #define allowAllUses 0xFF00
  107.  
  108.  
  109. /* ———— Error codes which the XTND System can return ———— */
  110.  
  111. #define badXTNDVersionErr -9991
  112.  
  113. #define noTransMatchErr -9999
  114.  
  115.  
  116. /* ———— Error codes which a translator can return ———— */
  117.  
  118. #define badImportFileErr 12
  119.  
  120. #define translationCanceledErr 32767
  121.  
  122.  
  123. /* ——————  T Y P E   D E F I N I T I O N S  —————— */
  124.  
  125. #ifndef __XTND__
  126. typedef pascal short (*XTNDDlgHookProcPtr)(short theItem, DialogPtr theDialog, Ptr theSFParams, Boolean *changedFlag, long unused);
  127.  
  128. enum {
  129.     uppXTNDDlgHookProcInfo = kPascalStackBased
  130.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  131.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  132.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr)))
  133.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr)))
  134.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Boolean*)))
  135.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  136. };
  137.  
  138. #if USESROUTINEDESCRIPTORS
  139. typedef UniversalProcPtr XTNDDlgHookUPP;
  140.  
  141. #define CallXTNDDlgHookProc(userRoutine, theItem, theDialog, theSFParams, changedFlag, unused)        \
  142.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppXTNDDlgHookProcInfo, (theItem), (theDialog), (theSFParams), (changedFlag), (unused))
  143. #define NewXTNDDlgHookProc(userRoutine)        \
  144.         (XTNDDlgHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppXTNDDlgHookProcInfo, GetCurrentISA())
  145. #else
  146. typedef XTNDDlgHookProcPtr XTNDDlgHookUPP;
  147.  
  148. #define CallXTNDDlgHookProc(userRoutine, theItem, theDialog, theSFParams, changedFlag, unused)        \
  149.         (*(userRoutine))((theItem), (theDialog), (theSFParams), (changedFlag), (unused))
  150. #define NewXTNDDlgHookProc(userRoutine)        \
  151.         (XTNDDlgHookUPP)(userRoutine)
  152. #endif
  153.  
  154.  
  155. /* ———— Translator procedure pointer.  Used for calling external code resources ———— */
  156.  
  157. typedef void (*TransProcPtr)(void *paramBlk);
  158.  
  159. enum {
  160.     uppTransProcInfo = kCStackBased
  161.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void*)))
  162. };
  163.  
  164. #if USESROUTINEDESCRIPTORS
  165. typedef UniversalProcPtr TransUPP;
  166.  
  167. #define CallTransProc(userRoutine, paramBlk)        \
  168.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppTransProcInfo, (paramBlk))
  169. #define NewTransProc(userRoutine)        \
  170.         (TransUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTransProcInfo, GetCurrentISA())
  171. #else
  172. typedef TransProcPtr TransUPP;
  173.  
  174. #define CallTransProc(userRoutine, paramBlk)        \
  175.         (*(userRoutine))((paramBlk))
  176. #define NewTransProc(userRoutine)        \
  177.         (TransUPP)(userRoutine)
  178. #endif
  179.  
  180.  
  181. /* —————— TransDescribe and Related Structures —————— */
  182.  
  183.  
  184. /* The MatchInfo data stucture defines a single file type (and possibly creator type)    */
  185.  
  186.  
  187. /* that a translator can recognize.                                                        */
  188.  
  189. #if defined(powerc) || defined (__powerc)
  190. #pragma options align=mac68k
  191. #endif
  192. struct MatchInfo {
  193.     ResType                        docCreator;                        /* Document creator, eg MACA - MacWrite    */
  194.     ResType                        docType;                        /* Document type, eg WORD - MacWrite    */
  195.     Boolean                        exactMatch;                        /* If TRUE, Creator MUST match            */
  196.     Byte                        creatorAndTypeMask;                /* Flags telling which bytes of creator & file type matter; creator is bits 0 - 3 and file type is bits 4 - 7    */
  197. };
  198. #if defined(powerc) || defined(__powerc)
  199. #pragma options align=reset
  200. #endif
  201.  
  202. typedef struct MatchInfo MatchInfo;
  203.  
  204.  
  205. /* The TransDescribe data stucture defines an import/export translator.  There is one    */
  206.  
  207.  
  208. /* of these (corresponds to the 'FTYP' resource) for every import/export translator.    */
  209.  
  210. #if defined(powerc) || defined (__powerc)
  211. #pragma options align=mac68k
  212. #endif
  213. struct TransDescribe {
  214.     short                        version;                        /* Version of this FTYP (currently 2) */
  215.     ResType                        translatorType;                    /* Type of translator (ie, 'PFLT' for pictures) */
  216.     short                        codeResID;                        /* Resource number of translator code resource */
  217.     short                        FDIFResID;                        /* Resource ID of 'FDIF' (or -1 if none) */
  218.     short                        numVersBytes;                    /* Number of bytes for version check (zero if no check) */
  219.     long                        versBytesOffSet;                /* Offset into file for version check */
  220.     unsigned char                versBytes[16];                    /* Byte values we are looking for (max 16) */
  221.     short                        appWDRefNum;                    /* Internal XTND use only - WDRefNum of the directory containing the application */
  222.     short                        unused1;                        /* Reserved for future use - must be zero for this version */
  223.     short                        pathLength;                        /* Internal XTND use only - Number of times this file has been translated */
  224.     short                        flags;                            /* Flags for filter characteristics */
  225. /*    bit 0 - set if this filter won't work with All Available */
  226. /*    bit 1 - reserved for future use - must be zero for this version */
  227. /*    bit 2 - set if this filter must be able to read its resources */
  228. /*    bit 3 - 4 reserved for future use - must be zero for this version */
  229. /*    bit 5 - set if this filter is localized to a particular language */
  230. /*     bit 6 - 13 reserved for future use - must be zero for this version */
  231. /*  bit 14 - 15 Used internally - must be zero for this version */
  232.     short                        transIndex;                        /* Internal XTND use only - Index of this translator in the list stored by the FINI */
  233.     short                        resRefNum;                        /* RefNum of resource fork of the translator file when open */
  234.     long                        directoryID;                    /* Directory ID of the folder containing the filter */
  235.     short                        vRefNum;                        /* Volume RefNum of volume which contains filter directory */
  236.     unsigned char                fileName[32];                    /* Name of file if this is an external filter            */
  237.     short                        numMatches;                        /* Number of Matches for this translator (0 means all files) */
  238.     MatchInfo                    matches[10];                    /* An array of all file matches for this translator */
  239.     unsigned char                name[32];                        /* Description of translator - appears in pop-up menus */
  240. };
  241. #if defined(powerc) || defined(__powerc)
  242. #pragma options align=reset
  243. #endif
  244.  
  245. typedef struct TransDescribe TransDescribe;
  246.  
  247. typedef TransDescribe *TransDescrPtr, **TransDescrHandle;
  248.  
  249. #if defined(powerc) || defined (__powerc)
  250. #pragma options align=mac68k
  251. #endif
  252. struct SFParamBlock {
  253. /* The following fields must be the same in this structure and MatchTranslatorBlock */
  254.     long                        allowFlags;                        /* --> Flags which indicate Translators to be used */
  255.     long                        numStandard;                    /* --> How many "standard" file types */
  256.     TransDescrPtr                standard;                        /* --> Native file format information */
  257.     OSErr                        ioResult;                        /* <-- Errors reported through this variable */
  258.     short                        chosenTranslator;                /* <-> On input, number of translators supplied in theChosenTranslator; on output, chosen Translator number */
  259.     TransDescrPtr                theChosenTranslator;            /* <-> On input, Pointer to list of translators to build popup menu from (UseMyTransList must be true if you supply this list); on output, pointer to the Chosen Translator */
  260. /* End of common fields */
  261.     SFReply                        *fileReply;                        /* <-- File information is returned through this pointer */
  262.     ResType                        applicNativeType;                /* --> Application native document file type, for use when library cannot be found */
  263.     XTNDDlgHookUPP                XTNDDlogHook;                    /* --> Pointer to your SF dialog hook */
  264.     short                        currentMenuItem;                /* <-- chosen menu item (GetFile) */
  265.     short                        currentSaveItem;                /* <-- chosen menu item (PutFile) */
  266.     Point                        where;                            /* --> Top left corner of dialog, if zero, center on screen */
  267.     StringPtr                    prompt;                            /* --> Pascal string which is displayed on dialog */
  268.     StringPtr                    buttonTitle;                    /* --> Pascal string which replaces the "Open" or "Save" button */
  269.     StringPtr                    origName;                        /* --> Pascal string which is the original name in a PutFile */
  270.     short                        dialogID;                        /* --> Resource number of your dialog template */
  271.     ModalFilterUPP                SFFilterProc;                    /* --> Pointer to your modal dialog filter proc */
  272.     Boolean                        showAllFiles;                    /* --> TRUE if you want all files to be shown */
  273.     Boolean                        useTransList;                    /* --> TRUE if you are using chosenTranslator and theChosenTranslator to input a list of translators to be used in creating the popup menu */
  274.     FileFilterUPP                myFileFilter;                    /* --> Pointer to your SF Filter Proc */
  275.     long                        unused[1];                        /* Reserved for future use, must be zero */
  276. };
  277. #if defined(powerc) || defined(__powerc)
  278. #pragma options align=reset
  279. #endif
  280.  
  281. typedef struct SFParamBlock SFParamBlock;
  282.  
  283. typedef SFParamBlock *SFParamPtr;
  284.  
  285.  
  286. /* This parameter block is used to find a translator to read a file */
  287.  
  288. #if defined(powerc) || defined (__powerc)
  289. #pragma options align=mac68k
  290. #endif
  291. struct MatchTranslatorBlock {
  292. /* The following fields must be the same in this structure and in ClarisFileParamBlock */
  293.     long                        allowFlags;                        /* --> Flags which indicate Translators to be used */
  294.     long                        numStandard;                    /* --> How many "standard" file types */
  295.     TransDescrPtr                standard;                        /* --> Array of "Native" file formats */
  296.     OSErr                        ioResult;                        /* <-- IO Result from Claris library */
  297.     short                        chosenTranslator;                /* <-> On input, number of translators supplied in theChosenTranslator; on output, chosen Translator number */
  298.     TransDescrPtr                theChosenTranslator;            /* <-> On input, Pointer to list of translators to build popup menu from (UseMyTransList must be true if you supply this list); on output, pointer to the Chosen Translator */
  299. /* End of common fields */
  300.     StringPtr                    fileName;                        /* --> File name */
  301.     short                        vRefNum;                        /* --> Volume Reference Number of file */
  302.     long                        ioDirID;                        /* --> Directory id of file */
  303.     Boolean                        initFlag;                        /* --> TRUE if the list of translators should be rebuilt */
  304.     Boolean                        useTransList;                    /* --> TRUE if you are using chosenTranslator and theChosenTranslator to input a list of translators to be used in creating the popup menu */
  305.     TransDescrPtr                oneTrans;                        /* --> If this is supplied, it will be tried instead of searching all available translators */
  306.     long                        unused[4];                        /* Reserved for future use, must be zero */
  307. };
  308. #if defined(powerc) || defined(__powerc)
  309. #pragma options align=reset
  310. #endif
  311.  
  312. typedef struct MatchTranslatorBlock MatchTranslatorBlock;
  313.  
  314. typedef MatchTranslatorBlock *MatchTranslatorPtr;
  315.  
  316. #if defined(powerc) || defined (__powerc)
  317. #pragma options align=mac68k
  318. #endif
  319. struct SelectParamBlock {
  320.     short                        translatorVersion;                /* To select by translator type */
  321.     ResType                        translatorType;                    /* and version */
  322.     long                        includeFlags;                    /* Include any of these translator types */
  323.     long                        excludeFlags;                    /* Exclude all of these translator types */
  324.     short                        includeTrans;                    /* Include translators with any of these flags set */
  325.     short                        excludeTrans;                    /* Excluded translator with any of these flags set */
  326.     StringPtr                    transName;                        /* Include only translators with this name */
  327.     long                        PBVersion;                        /* ••• MUST be ONE (1) for this version ••• */
  328.     Boolean                        menuSortFlag;                    /* TRUE if you want the list sorted and duplicates removed as when the XTND System creates a menu in ClarisGetFile or ClarisPutFile for you */
  329.     Boolean                        unused1;                        /* Reserved for future use, must be zero */
  330.     short                        unused2;                        /* Reserved for future use, must be zero */
  331.     long                        unused[4];                        /* Reserved for future use, must be zero */
  332. };
  333. #if defined(powerc) || defined(__powerc)
  334. #pragma options align=reset
  335. #endif
  336.  
  337. typedef struct SelectParamBlock SelectParamBlock;
  338.  
  339. typedef SelectParamBlock *SelectParamPtr;
  340.  
  341.  
  342. /* ———— Prototypes for calls to the XTND system ———— */
  343.  
  344. extern pascal OSErr XTNDInitTranslators(short transVersion, StringPtr xtndSystemName, StringPtr clarisFolderName);
  345. extern pascal Boolean XTNDGetFile(SFParamPtr paramPtr);
  346. extern pascal Boolean XTNDPutFile(SFParamPtr paramPtr);
  347. extern pascal OSErr XTNDLoadTranslator(TransDescrPtr theTranslator, TransUPP *transResource);
  348. extern pascal OSErr XTNDReleaseTranslator(TransDescrPtr theTranslator);
  349. extern pascal void XTNDCloseTranslators(void);
  350. extern pascal OSErr XTNDRebuildTransList(void);
  351. extern pascal OSErr XTNDSelectTranslators(SelectParamPtr selectPtr, TransDescrHandle transHandle);
  352. extern pascal Boolean XTNDMatchFile(MatchTranslatorPtr matchPtr);
  353. #endif
  354.  
  355. #endif
  356.  
  357.